<?php
/**
 * Api短信接口，MPE用户需要操作大塑支付相关的操作时，调用此接口
 * @author Liuyi<liuy@pvc123.com>
 * @created 2016-12-17:03:42
 */
namespace api\service;
use api\service\interfaces\ISmsService;
use herosphp\bean\Beans;
use herosphp\core\Loader;
use herosphp\utils\AjaxResult;
Loader::import('api.service.interfaces.ISmsService');
class SmsService implements ISmsService{

    private $__service = null;
    public function __construct()
    {
        $this -> __service = Beans::get('sms.sms.service');
    }

    public function getSMS($rule, $data, $mobile)
    {
        // TODO: Implement getSMS() method.
        if( !$rule || !$mobile ){
            return new AjaxResult(AjaxResult::OP_FAILURE,"error params",null);
        }
        $contents = $this -> __service -> build( $rule, $data );
        if($this -> __service -> send( $contents, $mobile )){
            return new AjaxResult(AjaxResult::OP_SUCCESS,"success",null);
        }else{
            return new AjaxResult(AjaxResult::OP_FAILURE,"send error",null);
        }
    }

}